package cn.com.pc.content.dto;

import cn.com.pc.content.domain.*;
import cn.com.pc.content.domain.audit.AuditStatus;
import cn.com.pc.content.domain.content.Author;
import cn.com.pc.content.domain.content.CoverImage;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 文章表单
 */
@Data
@ToString
public abstract class ContentDTO implements Serializable {

    private String id;
    private Site site;
    private Biz biz;
    private App app;
    @NotBlank(message = "referId不能为空")
    private String referId;
    private String title;
    private String summary;
    private Set<String> keywords;
    private List<CoverImage> coverImages;
    private Set<Long> tagIds;
    private List<String> tagNames;
    @NotNull(message = "author不能为空")
    private Author author;
    private String ip;
    private AuditStatus auditStatus;
    private int risk;
    private double weight;
    private Map<String, Object> metaData;
    private Map<String, Integer> statData;
    private Boolean onShelve;

    @JsonFormat(timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss", shape = JsonFormat.Shape.STRING)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime taggedAt;

    private String taggedBy;

    @JsonFormat(timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss", shape = JsonFormat.Shape.STRING)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createdAt;

    private String createdBy;

    @JsonFormat(timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss", shape = JsonFormat.Shape.STRING)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime updatedAt;

    private String updatedBy;

}
